using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class AlternateCharacterSetsAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public AlternateCharacterSetsAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v23] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v231] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v24] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v27] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v23] = new string[]{"8859/1","8859/2","8859/3","8859/4","8859/5","8859/6","8859/7","8859/8","8859/9","ASCII","JAS2020","JIS X 0202","UNICODE"};
						validVersionCodes[HL7Version.v231] = new string[]{"ASCII","8859/1","8859/2","8859/3","8859/4","8859/5","8859/6","8859/7","8859/8","8859/9","ISO IR14","ISO IR87","ISO IR159","UNICODE"};
						validVersionCodes[HL7Version.v24] = new string[]{"ASCII","8859/1","8859/2","8859/3","8859/4","8859/5","8859/6","8859/7","8859/8","8859/9","ISO IR14","ISO IR87","ISO IR159","UNICODE"};
						validVersionCodes[HL7Version.v25] = new string[]{"ASCII","8859/1","8859/2","8859/3","8859/4","8859/5","8859/6","8859/7","8859/8","8859/9","ISO IR14","ISO IR87","ISO IR159","GB 18030-2000","KS X 1001","CNS 11643-1992","BIG-5","UNICODE","UNICODE UTF-8","UNICODE UTF-16","UNICODE UTF-32"};
						validVersionCodes[HL7Version.v251] = new string[]{"ASCII","8859/1","8859/2","8859/3","8859/4","8859/5","8859/6","8859/7","8859/8","8859/9","ISO IR14","ISO IR87","ISO IR159","GB 18030-2000","KS X 1001","CNS 11643-1992","BIG-5","UNICODE","UNICODE UTF-8","UNICODE UTF-16","UNICODE UTF-32"};
						validVersionCodes[HL7Version.v26] = new string[]{"ASCII","8859/1","8859/2","8859/3","8859/4","8859/5","8859/6","8859/7","8859/8","8859/9","8859/15","ISO IR14","ISO IR87","ISO IR159","GB 18030-2000","KS X 1001","CNS 11643-1992","BIG-5","UNICODE","UNICODE UTF-8","UNICODE UTF-16","UNICODE UTF-32"};
						validVersionCodes[HL7Version.v27] = new string[]{"ASCII","8859/1","8859/2","8859/3","8859/4","8859/5","8859/6","8859/7","8859/8","8859/9","8859/15","ISO IR6","ISO IR14","ISO IR87","ISO IR159","GB 18030-2000","KS X 1001","CNS 11643-1992","BIG-5","UNICODE","UNICODE UTF-8","UNICODE UTF-16","UNICODE UTF-32"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v23] = new string[]{"The printable characters from the ISO 8859/1 Character set","The printable characters from the ISO 8859/2 Character set","The printable characters from the ISO 8859/3 Character set","The printable characters from the ISO 8859/4 Character set","The printable characters from the ISO 8859/5 Character set","The printable characters from the ISO 8859/6 Character set","The printable characters from the ISO 8859/7 Character set","The printable characters from the ISO 8859/8 Character set","The printable characters from the ISO 8859/9 Character set","The printable 7-bit ASCII character set . (This is the default if this field is omitted)","A subset of ISO2020 used for most Kanjii transmissions","ISO 2022 with escape sequences for Kanjii","<needs document reference>"};
						validVersionDescriptions[HL7Version.v231] = new string[]{"The printable 7-bit ASCII character set . (This is the default if this field is omitted)","The printable characters from the ISO 8859/1 Character set","The printable characters from the ISO 8859/2 Character set","The printable characters from the ISO 8859/3 Character set","The printable characters from the ISO 8859/4 Character set","The printable characters from the ISO 8859/5 Character set","The printable characters from the ISO 8859/6 Character set","The printable characters from the ISO 8859/7 Character set","The printable characters from the ISO 8859/8 Character set","The printable characters from the ISO 8859/9 Character set","Code for Information Exchange (one byte)(JIS X 0201-1976),  Note that the code contains a  space, i.e. \"ISO IR14\".","Code for the Japanese Graphic Character set for information interchange (JIS X 0208-1990), Note that the code contains a space, i.e. \"ISO IR87\".","Code of the supplementary Japanese Graphic Character set for information interchange (JIS X  0212-1990), Note that the code contains a space, i.e. \"ISO IR159\".","The world wide character standard from ISO/IEC 10646-1-1993"};
						validVersionDescriptions[HL7Version.v24] = new string[]{"The printable 7-bit ASCII character set. (This is the default if this field is omitted)","The printable characters from the ISO 8859/1 Character set","The printable characters from the ISO 8859/2 Character set","The printable characters from the ISO 8859/3 Character set","The printable characters from the ISO 8859/4 Character set","The printable characters from the ISO 8859/5 Character set","The printable characters from the ISO 8859/6 Character set","The printable characters from the ISO 8859/7 Character set","The printable characters from the ISO 8859/8 Character set","The printable characters from the ISO 8859/9 Character set","Code for Information Exchange (one byte)(JIS X 0201-1976).  Note that the code contains a space, i.e. \"ISO IR14\".","Code for the Japanese Graphic Character set for information interchange (JIS X 0208-1990), Note that the code contains a space, i.e. \"ISO IR87\".","Code of the supplementary Japanese Graphic Character set for information interchange (JIS X 0212-1990). Note that the code contains a space, i.e. \"ISO IR159\".","The world wide character standard from ISO/IEC 10646-1-19931"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"The printable 7-bit ASCII character set.","The printable characters from the ISO 8859/1 Character set","The printable characters from the ISO 8859/2 Character set","The printable characters from the ISO 8859/3 Character set","The printable characters from the ISO 8859/4 Character set","The printable characters from the ISO 8859/5 Character set","The printable characters from the ISO 8859/6 Character set","The printable characters from the ISO 8859/7 Character set","The printable characters from the ISO 8859/8 Character set","The printable characters from the ISO 8859/9 Character set","Code for Information Exchange (one byte)(JIS X 0201-1976).","Code for the Japanese Graphic Character set for information interchange (JIS X 0208-1990),","Code of the supplementary Japanese Graphic Character set for information interchange (JIS X 0212-1990).","Code for Chinese Character Set (GB 18030-2000)","Code for Korean Character Set (KS X 1001)","Code for Taiwanese Character Set (CNS 11643-1992)","Code for Taiwanese Character Set (BIG-5)","The world wide character standard from ISO/IEC 10646-1-1993","UCS Transformation Format, 8-bit form","UCS Transformation Format, 16-bit form","UCS Transformation Format, 32-bit form"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"The printable 7-bit ASCII character set.","The printable characters from the ISO 8859/1 Character set","The printable characters from the ISO 8859/2 Character set","The printable characters from the ISO 8859/3 Character set","The printable characters from the ISO 8859/4 Character set","The printable characters from the ISO 8859/5 Character set","The printable characters from the ISO 8859/6 Character set","The printable characters from the ISO 8859/7 Character set","The printable characters from the ISO 8859/8 Character set","The printable characters from the ISO 8859/9 Character set","Code for Information Exchange (one byte)(JIS X 0201-1976).","Code for the Japanese Graphic Character set for information interchange (JIS X 0208-1990),","Code of the supplementary Japanese Graphic Character set for information interchange (JIS X 0212-1990).","Code for Chinese Character Set (GB 18030-2000)","Code for Korean Character Set (KS X 1001)","Code for Taiwanese Character Set (CNS 11643-1992)","Code for Taiwanese Character Set (BIG-5)","The world wide character standard from ISO/IEC 10646-1-1993","UCS Transformation Format, 8-bit form","UCS Transformation Format, 16-bit form","UCS Transformation Format, 32-bit form"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"The printable 7-bit ASCII character set.","The printable characters from the ISO 8859/1 Character set","The printable characters from the ISO 8859/2 Character set","The printable characters from the ISO 8859/3 Character set","The printable characters from the ISO 8859/4 Character set","The printable characters from the ISO 8859/5 Character set","The printable characters from the ISO 8859/6 Character set","The printable characters from the ISO 8859/7 Character set","The printable characters from the ISO 8859/8 Character set","The printable characters from the ISO 8859/9 Character set","The printable characters from the ISO 8859/15 (Latin-15)","Code for Information Exchange (one byte)(JIS X 0201-1976).","Code for the Japanese Graphic Character set for information interchange (JIS X 0208-1990),","Code of the supplementary Japanese Graphic Character set for information interchange (JIS X 0212-1990).","Code for Chinese Character Set (GB 18030-2000)","Code for Korean Character Set (KS X 1001)","Code for Taiwanese Character Set (CNS 11643-1992)","Code for Taiwanese Character Set (BIG-5)","The world wide character standard from ISO/IEC 10646-1-1993","UCS Transformation Format, 8-bit form","UCS Transformation Format, 16-bit form","UCS Transformation Format, 32-bit form"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"The printable 7-bit ASCII character set.","The printable characters from the ISO 8859/1 Character set","The printable characters from the ISO 8859/2 Character set","The printable characters from the ISO 8859/3 Character set","The printable characters from the ISO 8859/4 Character set","The printable characters from the ISO 8859/5 Character set","The printable characters from the ISO 8859/6 Character set","The printable characters from the ISO 8859/7 Character set","The printable characters from the ISO 8859/8 Character set","The printable characters from the ISO 8859/9 Character set","The printable characters from the ISO 8859/15 (Latin-15)","ASCII graphic character set consisting of 94 characters.","Code for Information Exchange (one byte)(JIS X 0201-1976).","Code for the Japanese Graphic Character set for information interchange (JIS X 0208-1990),","Code of the supplementary Japanese Graphic Character set for information interchange (JIS X 0212-1990).","Code for Chinese Character Set (GB 18030-2000)","Code for Korean Character Set (KS X 1001)","Code for Taiwanese Character Set (CNS 11643-1992)","Code for Taiwanese Character Set (BIG-5)","The world wide character standard from ISO/IEC 10646-1-1993","UCS Transformation Format, 8-bit form","UCS Transformation Format, 16-bit form","UCS Transformation Format, 32-bit form"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
